Skip to content

Add support for named implements in Go#1657

Merged
dicej merged 6 commits into
bytecodealliance:mainfrom
jfleitz:jfleitz/go-implements
Jul 20, 2026
Merged

Add support for named implements in Go#1657
dicej merged 6 commits into
bytecodealliance:mainfrom
jfleitz:jfleitz/go-implements

Conversation

@jfleitz

@jfleitz jfleitz commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #1642

Overview

In the scenario where you are importing the same interface under multiple names (implements feature in wasm), the Go generator only emitted the interface types from the first package, since there is a check for not adding a duplicate interface.

This change adds the Go package name to the Hash key instead of just TypeId, allowing for all interfaces to be exported in all packages. There is no concern on duplicate interfaces in the same package, since that would be a Go compile error.

C++ bin gen was also changed to support the implements feature as well, with using the derived namespace in the WorldKey (primary::Bucket, secondary::Bucket).

Testing

  • Added tests/codegen/issue1642.wit importing the same interface with two names (to test implements) as well as non-named (to test prior functionality)
  • Verified with local wit-bindgen go and re-generated the bindings for the implements-test project.

Signed-off-by: Jeremy Fleitz jeremy@cosmonic.com

jfleitz added 2 commits July 17, 2026 15:41
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
@alexcrichton
alexcrichton requested a review from dicej July 17, 2026 20:22
jfleitz added 2 commits July 17, 2026 16:40
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>

@dicej dicej left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, @jfleitz! LGTM; just a couple of suggestions inline.

Comment thread crates/go/src/lib.rs Outdated
Comment thread crates/go/src/lib.rs Outdated
jfleitz added 2 commits July 20, 2026 14:40
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
Signed-off-by: Jeremy Fleitz <jeremy@cosmonic.com>
@dicej
dicej added this pull request to the merge queue Jul 20, 2026
Merged via the queue into bytecodealliance:main with commit 50b799a Jul 20, 2026
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Go: resource failed to be generated for implements feature

2 participants